# -*- coding: utf-8 -*-

# Copyright 2003-2007 Jarek Zgoda <jarek.zgoda@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

"""About program box"""

__revision__ = '$Id: dlgabout.py 3 2007-08-11 12:24:01Z jarek.zgoda $'

import os
import webbrowser

import gtk

import const

def open_url_hook(dialog, url, user_data):
    webbrowser.open_new_tab(url)

def show_about_dialog():
    dlg = gtk.AboutDialog()
    try:
        gtk.about_dialog_set_url_hook(open_url_hook, None)
        dlg.set_icon_from_file(const.APP_ICON)
        dlg.set_name('Leech.fm')
        dlg.set_version(const.VERSION_STRING)
        dlg.set_comments(_('A perfect marriage between Last.fm and torrentz.com'))
        dlg.set_website('http://code.google.com/p/leechfm/')
        fp = open(os.path.join(const.BASE_DIR, 'doc', 'AUTHORS'))
        try:
            lines = fp.read().strip().split('\n')
        finally:
            fp.close()
        dlg.set_authors(lines)
        dlg.set_copyright('Copyright: (c) 2007, Jarek Zgoda')
        fp = open(os.path.join(const.BASE_DIR, 'doc', 'COPYING'))
        try:
            license_text = fp.read().strip()
        finally:
            fp.close()
        dlg.set_license(license_text)
        dlg.run()
    finally:
        dlg.destroy()
